using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace IReaper.VideoPlay
{
    public class PlayListCollection : ICollection
    {

        private SortedList list = new SortedList();

        public PlayListCollection()
        {
        }

        public void Add(ListItem item)
        {
            if (list.IndexOfKey(item.Key) == -1)
            {
                list.Add(item.Key, item);
            }
        }

        public int IndexOfKey(string key)
        {
            return list.IndexOfKey(key);
        }

        public ICollection AllKeys
        {
            get
            {
                return list.Keys;
            }
        }

        public ListItem this[string key]
        {
            get
            {
                int dex = list.IndexOfKey(key);
                return this[dex];
            }
        }

        public ListItem this[int index]
        {

            get { return (ListItem)list.GetByIndex(index); }

        }

        #region ICollection Members

        public void CopyTo(Array array, int index)
        {
            list.CopyTo(array, index);
        }

        public int Count
        {
            get 
            {
                return list.Count;
            }
        }

        public bool IsSynchronized
        {
            get 
            {
                return false;
            }
        }

        public object SyncRoot
        {
            get 
            {
                return this;
            }
        }

        #endregion

        #region IEnumerable Members

        public IEnumerator GetEnumerator()
        {
            return list.GetEnumerator();
        }

        #endregion
    }
}
